// TextPairs.h

#ifndef __FM_TEXT_PAIRS_H
#define __FM_TEXT_PAIRS_H

#include <vector>


namespace Common
{
namespace String
{

	//Check the usage of these types. Maybe it can be dropped

struct CTextPair
{
  CString ID;
  CString Value;
  CTextPair(const CString & id, const CString & v) :
	  ID(id), Value(v)
  {}
  CTextPair() {}
  CTextPair(const CTextPair & obj) :
	  ID(obj.ID), Value(obj.Value)	  
  {}
  CTextPair & operator=(const CTextPair & obj)
  {
	  ID = obj.ID;
	  Value = obj.Value;
	  return *this;
  }
};

class CPairsStorage
{
  std::vector<CTextPair> Pairs;
  int FindID(const CString &id, int &insertPos);
  int FindID(const CString &id);
  void Sort();
public:
  void Clear() { Pairs.clear(); };
  bool ReadFromString(const CString &text);
  void SaveToString(CString &text);

  bool GetValue(const CString &id, CString &value);
  CString GetValue(const CString &id);
  void AddPair(const CTextPair &pair);
  void DeletePair(const CString &id);
};

}
}
#endif
